import { _decorator, Component, instantiate, Node, Prefab,find } from 'cc';
import { ShootBullet } from './ShootBullet';
import { TankMove } from './TankMove';
import { AudioMgr } from '../../AudioMgr/AudioMgr';
import { GameMgr } from '../GameMgr';
const { ccclass, property } = _decorator;

@ccclass('TankShoot')
export class TankShoot extends Component {

    @property(Prefab)
     bullet:Prefab=null;

    @property tankMove:TankMove=null;

    @property bulletDamage:number=1;

    protected onLoad(): void {
        this.tankMove=this.getComponent(TankMove);
        this.bulletDamage=GameMgr.Inst.getQuickTime(this.bulletDamage,10);
    }

    protected start(): void {

    }
    
    shoot(){

      
        //console.log("shoot");
        let b:Node =instantiate(this.bullet);
        find("Canvas/bullets").addChild(b);
        let bSB:ShootBullet=b.getComponent(ShootBullet);
        bSB.init(this.tankMove.getDir(),this.node.getPosition(),this.bulletDamage);

    }

    eatDamageProp(){
        this.bulletDamage=2;
    }
}


